home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
amiga
/
CDDevice.mod
< prev
next >
Wrap
Text File
|
1995-06-29
|
16KB
|
370 lines
(*************************************************************************
$RCSfile: CDDevice.mod $
Description: Interface to cd.device
Created by: fjc (Frank Copeland)
$Revision: 3.7 $
$Author: fjc $
$Date: 1995/06/04 23:13:14 $
$VER: cd.h 1.11 (12.8.93)
Includes Release 40.15
(C) Copyright 1992-1993 Commodore-Amiga, Inc.
All Rights Reserved
Oberon-A Interface Copyright © 1994-1995, Frank Copeland.
This file is part of the Oberon-A Interface.
See Oberon-A.doc for conditions of use and distribution.
*************************************************************************)
<* STANDARD- *>
MODULE [2] CDDevice;
IMPORT e := Exec;
(**************************************************************************
* *
* CD Commands *
* *
**************************************************************************)
CONST
reset * = 1;
read * = 2;
write * = 3;
update * = 4;
clear * = 5;
stop * = 6;
start * = 7;
flush * = 8;
motor * = 9;
seek * = 10;
format * = 11;
remove * = 12;
changeNum * = 13;
changeState * = 14;
protStatus * = 15;
getDriveType * = 18;
getNumTracks * = 19;
addChangeInt * = 20;
remChangeInt * = 21;
getGeometry * = 22;
eject * = 23;
info * = 32;
config * = 33;
tocMSF * = 34;
tocLSN * = 35;
readXL * = 36;
playTrack * = 37;
playMSF * = 38;
playLSN * = 39;
pause * = 40;
search * = 41;
qCodeMSF * = 42;
qCodeLSN * = 43;
attenuate * = 44;
addFrameInt * = 45;
remFrameInt * = 46;
(**************************************************************************
* *
* Device Driver Error Codes *
* *
**************************************************************************)
CONST
errOpenFail * = -1; (* device/unit failed to open *)
errAborted * = -2; (* request terminated early *)
errNoCmd * = -3; (* command not supported by device *)
errBadLength * = -4; (* invalid length (IO_LENGTH/IO_OFFSET) *)
errBadAddress * = -5; (* invalid address (IO_DATA misaligned) *)
errUnitBusy * = -6; (* device opens ok, but unit is busy *)
errSelfTest * = -7; (* hardware failed self-test *)
errNotSpecified * = 20; (* general catchall *)
errNoSecHdr * = 21; (* couldn't even find a sector *)
errBadSecPreamble * = 22; (* sector looked wrong *)
errBadSecID * = 23; (* ditto *)
errBadHdrSum * = 24; (* header had incorrect checksum *)
errBadSecSum * = 25; (* data had incorrect checksum *)
errTooFewSecs * = 26; (* couldn't find enough sectors *)
errBadSecHdr * = 27; (* another "sector looked wrong" *)
errWriteProt * = 28; (* can't write to a protected disk *)
errNoDisk * = 29; (* no disk in the drive *)
errSeekError * = 30; (* couldn't find track 0 *)
errNoMem * = 31; (* ran out of memory *)
errBadUnitNum * = 32; (* asked for a unit > NUMUNITS *)
errBadDriveType * = 33; (* not a drive cd.device understands *)
errDriveInUse * = 34; (* someone else allocated the drive *)
errPostReset * = 35; (* user hit reset; awaiting doom *)
errBadDataType * = 36; (* data on disk is wrong type *)
errInvalidState * = 37; (* invalid cmd under current conditions *)
errPhase * = 42; (* illegal or unexpected SCSI phase *)
errNoBoard * = 50; (* open failed for non-existant board *)
(**************************************************************************
* *
* Configuration *
* *
* The drive is configured by TagList items defined as follows: *
* *
**************************************************************************)
CONST
playSpeed * = 00001H;
readSpeed * = 00002H;
readXLSpeed * = 00003H;
sectorSize * = 00004H;
xlECC * = 00005H;
ejectReset * = 00006H;
(**************************************************************************
* *
* Information *
* *
* Information/Status structure describes current speed settings *
* for read and play commands, sector size, audio attenuation *
* precision, and drive status. *
* *
**************************************************************************)
TYPE
CDInfoPtr * = POINTER TO CDInfo;
CDInfo * = RECORD (* Default *)
playSpeed * : e.UWORD; (* Audio play speed (75) *)
readSpeed * : e.UWORD; (* Data-rate of CD_READ command (Max) *)
readXLSpeed * : e.UWORD; (* Data-rate of CD_READXL command (75) *)
sectorSize * : e.UWORD; (* Number of bytes per sector (2048) *)
xlECC * : e.UWORD; (* CDXL ECC enabled/disabled *)
ejectReset * : e.UWORD; (* Reset on eject enabled/disabled *)
reserved1 * : ARRAY 4 OF e.UWORD; (* Reserved for future expansion *)
maxSpeed * : e.UWORD; (* Maximum speed drive can handle (75, 150) *)
audioPrecision * : e.UWORD; (* 0 = no attenuator, 1 = mute only, *)
(* other = (# levels - 1) *)
status * : e.UWORD; (* See flags below *)
reserved2 * : ARRAY 4 OF e.UWORD; (* Reserved for future expansion *)
END;
CONST
(* Flags for Status *)
stsbClosed * = 0; (* Drive door is closed *)
stsbDisk * = 1; (* A disk has been detected *)
stsbSpin * = 2; (* Disk is spinning (motor is on) *)
stsbTOC * = 3; (* Table of contents read. Disk is valid. *)
stsbCDRom * = 4; (* Track 1 contains CD-ROM data *)
stsbPlaying * = 5; (* Audio is playing *)
stsbPaused * = 6; (* Pause mode (pauses on play command) *)
stsbSearch * = 7; (* Search mode (Fast Forward/Fast Reverse) *)
stsbDirection * = 8; (* Search direction (0 = Forward, 1 = Reverse) *)
(* Modes for CD_SEARCH *)
normal * = 0; (* Normal play at current play speed *)
fFwd * = 1; (* Fast forward play (skip-play forward)*)
fRev * = 2; (* Fast reverse play (skip-play reverse)*)
(**************************************************************************
* *
* Position Information *
* *
* Position information can be described in two forms: MSF and LSN *
* form. MSF (Minutes, Seconds, Frames) form is a time encoding. *
* LSN (Logical Sector Number) form is frame (sector) count. *
* The desired form is selected using the io_Flags field of the *
* IOStdReq structure. The flags and the union are described *
* below. *
* *
**************************************************************************)
TYPE
RMSFPtr * = POINTER TO RMSF;
RMSF * = RECORD
reserved * : SHORTINT; (* Reserved (always zero) *)
minute * : SHORTINT; (* Minutes (0-72ish) *)
second * : SHORTINT; (* Seconds (0-59) *)
frame * : SHORTINT; (* Frame (0-74) *)
END;
RLSNPtr * = POINTER TO RLSN;
RLSN * = RECORD
lsn * : e.ULONG; (* Logical Sector Number *)
END;
(**************************************************************************
* *
* CD Transfer Lists *
* *
* A CDXL node is a double link node; however only single linkage *
* is used by the device driver. If you wish to construct a *
* transfer list manually, it is only neccessary to define the *
* mln_Succ pointer of the MinNode. You may also use the Exec *
* list functions by defining a List or MinList structure and by *
* using the AddHead/AddTail functions to create the list. This *
* will create a double-linked list. Although a double-linked *
* list is not required by the device driver, you may wish use it *
* for your own purposes. Don't forget to initialize the *
* the List/MinList before using it! *
* *
**************************************************************************)
TYPE
CDXLPtr * = POINTER TO CDXL;
CDXL * = RECORD (e.MinNodeBase)
node * : e.MinNode; (* double linkage *)
buffer * : e.APTR; (* data destination (word aligned) *)
length * : LONGINT; (* must be even # bytes *)
actual * : LONGINT; (* bytes transferred *)
intData * : e.APTR; (* interrupt server data segment *)
IntCode * : e.PROC; (* interrupt server code entry *)
END;
(**************************************************************************
* *
* CD Table of Contents *
* *
* The CD_TOC command returns an array of CDTOC entries. *
* Entry zero contains summary information describing how many *
* tracks the disk has and the play-time of the disk. *
* Entries 1 through N (N = Number of tracks on disk) contain *
* information about the track. *
* *
**************************************************************************)
TYPE
TOCSummary * = RECORD END;
TOCSummaryPtr *= POINTER TO TOCSummary;
TOCSummaryMSFPtr * = POINTER TO TOCSummaryMSF;
TOCSummaryMSF * = RECORD (TOCSummary)
firstTrack * : SHORTINT; (* First track on disk (always 1) *)
lastTrack * : SHORTINT; (* Last track on disk *)
leadOut * : RMSF; (* Beginning of lead-out track (end of disk) *)
END;
TOCSummaryLSNPtr * = POINTER TO TOCSummaryLSN;
TOCSummaryLSN * = RECORD (TOCSummary)
firstTrack * : SHORTINT; (* First track on disk (always 1) *)
lastTrack * : SHORTINT; (* Last track on disk *)
leadOut * : RLSN; (* Beginning of lead-out track (end of disk) *)
END;
TOCEntry * = RECORD END;
TOCEntryPtr *= POINTER TO TOCEntry;
TOCEntryMSFPtr * = POINTER TO TOCEntryMSF;
TOCEntryMSF * = RECORD (TOCEntry)
ctlAdr * : SHORTINT; (* Q-Code info *)
track * : SHORTINT; (* Track number *)
position * : RMSF; (* Start position of this track *)
END;
TOCEntryLSNPtr * = POINTER TO TOCEntryLSN;
TOCEntryLSN * = RECORD (TOCEntry)
ctlAdr * : SHORTINT; (* Q-Code info *)
track * : SHORTINT; (* Track number *)
position * : RLSN; (* Start position of this track *)
END;
CDTOC * = RECORD END;
CDTOCPtr *= POINTER TO CDTOC;
CDTOCMSFPtr * = POINTER TO CDTOCMSF;
CDTOCMSF * = RECORD (CDTOC)
summary * : TOCSummaryMSF; (* First entry (0) is summary information *)
entry * : ARRAY 256 OF TOCEntryMSF; (* Entries 1-N are track entries *)
END;
CDTOCLSNPtr * = POINTER TO CDTOCLSN;
CDTOCLSN * = RECORD (CDTOC)
summary * : TOCSummaryLSN; (* First entry (0) is summary information *)
entry * : ARRAY 256 OF TOCEntryLSN; (* Entries 1-N are track entries *)
END;
(**************************************************************************
* *
* Q-Code Packets *
* *
* Q-Code packets are only returned when audio is playing. *
* Currently, only position packets are returned (ADR_POSITION) *
* The other ADR_ types are almost never encoded on the disk *
* and are of little use anyway. To avoid making the QCode *
* structure a union, these other ADR_ structures are not defined. *
* *
**************************************************************************)
TYPE
QCodeMSFPtr * = POINTER TO QCodeMSF;
QCodeMSF * = RECORD
ctlAdr * : SHORTINT; (* Data type / QCode type *)
track * : SHORTINT; (* Track number *)
index * : SHORTINT; (* Track subindex number *)
zero * : SHORTINT; (* The "Zero" byte of Q-Code packet *)
trackPosition * : RMSF; (* Position from start of track *)
diskPosition * : RMSF; (* Position from start of disk *)
END;
QCodeLSNPtr * = POINTER TO QCodeLSN;
QCodeLSN * = RECORD
ctlAdr * : SHORTINT; (* Data type / QCode type *)
track * : SHORTINT; (* Track number *)
index * : SHORTINT; (* Track subindex number *)
zero * : SHORTINT; (* The "Zero" byte of Q-Code packet *)
trackPosition * : RLSN; (* Position from start of track *)
diskPosition * : RLSN; (* Position from start of disk *)
END;
CONST
ctlAdrCtlMask * = 0F0H; (* Control field *)
ctlCtlMask * = 0D0H; (* To be ANDed with CtlAdr before compared *)
ctl2Aud * = 000H; (* 2 audio channels without preemphasis *)
ctl2AudEmph * = 010H; (* 2 audio channels with preemphasis *)
ctl4Aud * = 080H; (* 4 audio channels without preemphasis *)
ctl4AudEmph * = 090H; (* 4 audio channels with preemphasis *)
ctlData * = 040H; (* CD-ROM Data *)
ctlCopyMask * = 020H; (* To be ANDed with CtlAdr before compared *)
ctlCopy * = 020H; (* When true, this audio/data can be copied *)
ctlAdrAdrMask * = 00FH; (* Address field *)
adrPosition * = 001H; (* Q-Code is position information *)
adrUPC * = 002H; (* Q-Code is UPC information (not used) *)
adrISRC * = 003H; (* Q-Code is ISRC (not used) *)
adrHybrid * = 005H; (* This disk is a hybrid disk *)
END CDDevice.